#include "qtreeviewstudialog.h"
#include "ui_qtreeviewstudialog.h"
#include "../../b-model/02-q_project_model/projectmodel.h"


QTreeViewStuDialog::QTreeViewStuDialog(QWidget *parent)
    : QDialog(parent)
    , ui(new Ui::QTreeViewStuDialog)
{
    ui->setupUi(this);

    model1 = new QStandardItemModel();
    ui->tv_defualt->setModel(model1);

    model2 = new QProjectModel();
    ui->tv_project->setModel(model2);

    // ->setModel(model);

}

QTreeViewStuDialog::~QTreeViewStuDialog()
{
    delete ui;
}

void QTreeViewStuDialog::on_pushButton_clicked()
{
    QStandardItem * item1 = new QStandardItem("Project1");
    model1->appendRow(item1);
    QStandardItem * item2 = new QStandardItem("Project2");
    model1->appendRow(item2);
}


//root的索引是 QModelIndex();
void QTreeViewStuDialog::on_pushButton_2_clicked()
{
    ProjectModel * m = new ProjectModel();
    m->title = "111";
    // QModelIndex indexRoot = QModelIndex();
    model2->appendRow(m);
}

